<?php

namespace App\Http\Resources\Admin\V1;

use Illuminate\Http\Resources\Json\ResourceCollection;

/**
 * @method currentPage()
 * @method perPage()
 * @method total()
 * @method lastPage()
 */
class AdminCollection extends ResourceCollection
{
    /**
     * @expalin 数据格式化
     * @param \Illuminate\Http\Request $request
     * @return array
     * @method
     * @author 陈文小超
     * @maxim from专注to执行
     * @time 2021/3/29/16:38
     */
    public function toArray($request)
    {
        return [
            'data' => $this->collection,
            'meta' => [
                'count'        => (int) $this->count(),
                'current_page' => (int) $this->currentPage(),
                'per_page'     => (int) $this->perPage(),
                'total'        => (int) $this->total(),
                'total_pages'  => (int) $this->lastPage(),
            ],
        ];
    }
}
